package com.gong.DesignPattern.IteratorPattern;

import java.util.concurrent.TimeUnit;

/**
 * @author GongChang
 * @version 1.0
 * @date 2021/6/26 0026 12:12
 */
public class Test {

    private static Object object = new Object();

    public static void main(String[] args) {
        new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(1);
                synchronized (object){
                    System.out.println("进来了");
                    object.wait();
                    System.out.println("22222");
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(()->{
            try {
                synchronized (object){
                    object.notifyAll();
                    System.out.println("333");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(1);
                synchronized (object){
                    System.out.println("444");
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
